<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>js原型链之系统构造函数原型</title>
</head>
<body>
  <ul>
    <li>以"字面量"形式定义的变量，其实都是new对应的系统构造函数的简写，因此其对应的__proto__仍然是构造函数的原型prototype</li>
    <li>不要"滥用"原型, 即不建议为系统构造函数(如Object,Array等)添加原型方法</li>
  </ul>
  <button onclick="this.hide()">点击隐藏</button>
  <script>
    const obj = {}        // new Object
    const arr = []        // new Array
    const str = ''        // new String
    const num = 0         // new Number
    const bool = false    // new Boolean
    const reg = /miracle/ // new RegExp
    console.log(obj.__proto__ === Object.prototype)   // true
    console.log(arr.__proto__ === Array.prototype)    // true
    console.log(str.__proto__ === String.prototype)   // true
    console.log(num.__proto__ === Number.prototype)   // true
    console.log(bool.__proto__ === Boolean.prototype) // true
    console.log(reg.__proto__ === RegExp.prototype)   // true
    // 为系统构造函数添加原型(不建议)
    Object.prototype.hide = function() {
      this.style.display = 'none'
    }
  </script>
  <script src="plugin.js"></script>
</body>
</html>